package cn.vinann.demo.config.dataSource;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration  
public class DataSourceConfig { 
	
	
	@Bean(name = "primaryDataSource")
    @ConfigurationProperties(prefix = "spring.jta.atomikos.datasource.one")
    @Primary
    public DataSource dataSourceOne() {
        return new AtomikosDataSourceBean();
    }

	@Bean(name = "secondaryDataSource")
    @ConfigurationProperties(prefix = "spring.jta.atomikos.datasource.two")
    public DataSource dataSourceTwo() {
        return new AtomikosDataSourceBean();
    }
    
}